package com.atguigu.multiReading;

public class demo14 {
    public static void main(String[] args) {
        String date="2019-01-09";
        System.out.println(Solution1.dayOfYear(date));
    }
}
class Solution1{
    public static int dayOfYear(String date){
        int res=0;
        int year=Integer.parseInt(date.substring(0,4));
        int month=Integer.parseInt(date.substring(5,7));
        int day=Integer.parseInt(date.substring(8,10));
        switch (month){
            case 1:res+=day;
            break;
            case 2:res=res+day+31;
            break;
            case 3:res=res+day+59;
            break;
            case 4:res=res+day+90;
            break;
            case 5:res=res+day+120;
            break;
            case 6:res=res+day+151;
            break;
            case 7:res=res+day+181;
            break;
            case 8:res=res+day+212;
            break;
            case 9:res=res+day+243;
            break;
            case 10:res=res+day+273;
            break;
            case 11:res=res+day+304;
            break;
            case 12:res=res+day+334;
            break;
        }
        if((year%4==0&&year%100!=0)||year%400==0){
            if(month>=3){
                res+=1;
            }
        }
        return res;
    }
}
